<extend name="Layout/ins_page" />
<block name="content">
    <link href="/sap/demo.css" rel="stylesheet" type="text/css" />
    <script src="/sap/scripts/boot.js" type="text/javascript"></script>



    <legend><span></span></legend>
    <div  id='fm1'>
        <div class="fieldset-body">

            <div id="tabs1" class="mini-tabs" activeIndex="0" style="width:100%;margin-top: 5px;overflow:auto;" plain="false"
                 buttons="#tabsButtons"
            >
                <div title="列表：" >

                    <div style="width:100%;">
                        <div class="mini-toolbar" style="border-bottom:0;padding:0px;">
                            <table style="width:100%;">
                                <tr>
                                    <td style="width:100%;">
                                        <a class="mini-button" iconCls="icon-remove" onclick="removeRow()" plain="true">删除</a>
                                        <a class="mini-button" iconCls="icon-save" onclick="saveData()" plain="true">保存</a>
                                    </td>

                                </tr>
                            </table>
                        </div>
                    </div>

                    <div id="datagrid1" class="mini-datagrid" style="height:430px;width: 100%;"
                         url="/Wkorder/getListUserFromExcel" idField="id"
                         allowResize="true"
                         allowCellEdit="true" allowCellSelect="true" multiSelect="true"
                         allowCellValid="true" oncellvalidation=""
                    >

                        <div property="columns">

                            <div type="checkcolumn"></div>

                            <div field="gt_emp_no"  headerAlign="center"  >工号
                                <input property="" class="mini-textbox" style="width:100%;" />
                            </div>

                            <div field="cn_name"  headerAlign="center"  >中文名
                                <input property="" class="mini-textbox" style="width:100%;" />
                            </div>

                            <div field="en_name"  headerAlign="center"  >英文名
                                <input property="" class="mini-textbox" style="width:100%;" />
                            </div>

                            <div field="pass_word"  headerAlign="center"  >密码
                                <input property="" class="mini-textbox" style="width:100%;" />
                            </div>

                            <div field="dept"  headerAlign="center"  >部门
                                <input property="" class="mini-textbox" style="width:100%;" />
                            </div>

                            <div field="group_name"  headerAlign="center"  >组
                                <input property="" class="mini-textbox" style="width:100%;" />
                            </div>

                            <div field="title"  headerAlign="center"  >职位
                                <input property="" class="mini-textbox" style="width:100%;" />
                            </div>

                            <div field="gender"  headerAlign="center"  >性别
                                <input property="" class="mini-textbox" style="width:100%;" />
                            </div>

                            <div field="mob_phone"  headerAlign="center"  >手机号
                                <input property="" class="mini-textbox" style="width:100%;" />
                            </div>

                            <div field="tel_ext"  headerAlign="center"  >分机号
                                <input property="" class="mini-textbox" style="width:100%;" />
                            </div>

                            <div field="gmt_create"  headerAlign="center"  >上传时间
                                <input property="" class="mini-textbox" style="width:100%;" />
                            </div>
                            <div field="upload_emp_no"  headerAlign="center"  >上传人
                                <input property="" class="mini-textbox" style="width:100%;" />
                            </div>
                            <div field="is_ok_domain"  headerAlign="center"  >创建域账号
                                <input property="" class="mini-textbox" style="width:100%;" />
                            </div>
                            <div field="error_msg_domain"  headerAlign="center"  >创建域账号错误信息
                                <input property="" class="mini-textbox" style="width:100%;" />
                            </div>

                            <div field="is_ok_email"  headerAlign="center"  >创建email账号
                                <input property="" class="mini-textbox" style="width:100%;" />
                            </div>
                            <div field="error_msg_email"  headerAlign="center"  >创建email账号错误信息
                                <input property="" class="mini-textbox" style="width:100%;" />
                            </div>

                            <div field="is_ok_qq"  headerAlign="center"  >创建QQ账号
                                <input property="" class="mini-textbox" style="width:100%;" />
                            </div>
                            <div field="error_msg_qq"  headerAlign="center"  >创建QQ账号错误信息
                                <input property="" class="mini-textbox" style="width:100%;" />
                            </div>

                            <!--<div field="generatePassword"  headerAlign="center"  >生成新密码-->
                                <!--<input property="" class="mini-textbox" style="width:100%;" />-->
                            <!--</div>-->

                            <!--<div field="create_all"  headerAlign="center"  >创建所有账号-->
                                <!--<input property="" class="mini-textbox" style="width:100%;" />-->
                            <!--</div>-->

                            <div field="generate_pdf"  headerAlign="center"  >生成PDF文件
                                <input property="" class="mini-textbox" style="width:100%;" />
                            </div>

                            <div field="create_domain"  headerAlign="center"  >创建域账号
                                <input property="" class="mini-textbox" style="width:100%;" />
                            </div>

                            <div field="create_email"  headerAlign="center"  >创建email账号
                                <input property="" class="mini-textbox" style="width:100%;" />
                            </div>

                            <div field="create_qq"  headerAlign="center"  >创建QQ账号
                                <input property="" class="mini-textbox" style="width:100%;" />
                            </div>

                        </div>
                    </div>
                </div>
                <!-- <div title="Tab2" iconCls="" >
                    2
                </div> -->
            </div>
        </div>
    </div>


    </body>
    <script type="text/javascript">
        mini.parse();
        var grid = mini.get("datagrid1");
        grid.setPageSize(50);
        grid.load();
        grid.on("drawcell", function (e) {
            var record = e.record,
                column = e.column,
                field = e.field,
                value = e.value;

            //格式化日期
            if (field == "gmt_create") {
                if (mini.isDate(value)) e.cellHtml = mini.formatDate(value, "yyyy-MM-dd HH:mm:ss");

            }

            if (field == "generatePassword") {
                e.cellHtml = '<a href="javascript:generatePassword('+record.id+')"  >生成新密码</a>';
            }

            if (field == "create_all") {
                e.cellHtml = '<a href="javascript:create('+record.id+',\'all\')"  >创建所有账号</a>';
            }

            if (field == "generate_pdf") {
                e.cellHtml = '<a href="javascript:generatePdf('+record.id+')"  >生成PDF文件</a>';
            }

            if (field == "create_domain") {
                e.cellHtml = '<a href="javascript:create('+record.id+',\'domain\')"  >创建域账号</a>';
            }

            if (field == "create_email") {
                e.cellHtml = '<a href="javascript:create('+record.id+',\'email\')"  >创建email账号</a>';
            }

            if (field == "create_qq") {
                e.cellHtml = '<a href="javascript:create('+record.id+',\'qq\')"  >创建QQ账号</a>';
            }

        });

        function showList(list_tag) {
            mini.open({
                url:  "/index.php?m=&c=SapSupplier&a=showupdatesapitemlist&list_tag="+list_tag,
                title: "清单细节",
                width: 800,
                height: 380,
                ondestroy: function (action) {
                    if (action == "ok") {

                    }

                }
            });

        }

        function generatePdf(id) {

            //确认提示
            mini.confirm("确定？", "确定？",
                function (action) {
                    if (action == "ok") {

                        // form
                        var f=document.createElement("form");
                        f.action="/Wkorder/generatePdf";
                        f.method="post";
                        f.innerHTML="<input type='hidden' name='id' value='"+id+"'/>";
                        document.body.appendChild(f);
                        f.submit()

                    } else {

                    }
                }
            );

        }

        function generatePassword(id) {

            //确认提示
            mini.confirm("确定？", "确定？",
                function (action) {
                    if (action == "ok") {

                        $.ajax({
                            url: "/Wkorder/generatePasswordForSpecialUser",
                            type: "post",
                            data: {id: id},
                            dataType: 'json',
                            success: function (data) {
                                mini.alert(data.msg);
                                grid.load();
                            }
                        });


                    } else {

                    }
                }
            );

        }

        function create(id,type) {

            //确认提示
            mini.confirm("确定？", "确定？",
                function (action) {
                    if (action == "ok") {

                        $.ajax({
                            url: "/Wkorder/doCreateUser",
                            type: "post",
                            data: {id: id, type: type},
                            dataType: 'json',
                            success: function (data) {
                                mini.alert(data.msg);
                                grid.load();
                            }
                        });


                    } else {

                    }
                }
            );

        }

        function removeRow() {
            var rows = grid.getSelecteds();
            if (rows.length > 0) {
                grid.removeRows(rows, true);
            }
        }

        function saveData() {

            var data = grid.getChanges();
            var json = mini.encode(data);

            grid.loading("保存中，请稍后......");
            $.ajax({
                url: "/wkorder/updateTableCreatedUserIt",
                data: { data: json },
                type: "post",
                success: function (text) {
                    grid.reload();
                },
                error: function (jqXHR, textStatus, errorThrown) {
                    alert(jqXHR.responseText);
                }
            });
        }

    </script>
</block>

